import cv2
if __name__=='__main__':
    image=cv2.imread("C:\\Users\\20436\Desktop\lunkuio.jpg")
    image_gray=cv2.cvtColor(
        image,
        cv2.COLOR_BGR2GRAY
    )
    _,image_thresh=cv2.threshold(
        image_gray,
        127,
        255,
        cv2.THRESH_BINARY_INV
    )
    _, image_thresh1 = cv2.threshold(
        image_gray,
        200,
        255,
        cv2.THRESH_BINARY
    )
    image_thresh_zong=cv2.bitwise_or(image_thresh,image_thresh1)
    contours,hierarchy=cv2.findContours(
        image_thresh_zong,
        cv2.RETR_CCOMP,
        cv2.CHAIN_APPROX_SIMPLE
    )
    image=cv2.drawContours(
        image,
        contours,
        contourIdx=-1,
        color=(0,0,0),
        thickness=2
    )
    cv2.imshow('kunkuo', image)
    cv2.imwrite('lunkuo.jpg', image)
    cv2.waitKey(0)